import React from 'react';
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import * as Action from "../actions";
import { HashRouter as Router, Route, Link } from 'react-router-dom'

import Header from "../header.js"
import Logo from "./logo.js";
class Welcome extends React.Component {
    constructor(props) {
        super(props);
        var searchObj = function searchObj(search) {
            return JSON.parse("{\"".concat(decodeURIComponent(search.substring(1)).replace(/&/g, '","').replace(/=/g, '":"'), "\"}"));
        };
        this.state=({
            userInfo : searchObj(props.location.search)
        })
        var location1 = {
            "storeId": parseInt(this.state.userInfo.storeId),
            "tableId": parseInt(this.state.userInfo.tableId),
            "userOpenid": this.state.userInfo.userOpenid,
        }
        var parm={
            "storeIcon": this.state.userInfo.storeIcon,
            "storeName": this.state.userInfo.storeName,
            "tableType": this.state.userInfo.tableType
        }
        window.sessionStorage["userOpenid"] = JSON.stringify(location1);

        this.props.actions.initstoreinfo(parm);
    }
    render() {
        document.title = "欢迎";
        return <Router>
            <div>
                <Header />
                <Logo logo={this.state.userInfo.storeIcon} />
                <footer>
                    <div className="price">
                        <span style={{ marginLeft: "30%" }}>欢迎光临本餐厅</span>
                    </div>
                    <div className="shopBtn">
                        <Link to="/product">点菜</Link>
                    </div>
                </footer>
            </div>
        </Router>
    }
}
export default connect(
    ({welcomeReducer})=>{
          
    },
    (dispatch) => {
        return {
            actions: bindActionCreators(Action,dispatch)
        }
    }
)(Welcome);

